package nl.vu.few.ibivu.biomodels.shared;

import java.io.Serializable;

import com.google.gwt.core.client.JavaScriptObject;

import nl.vu.few.ibivu.biomodels.client.ui.cytoscapeweb.CytoscapeWebNetworkModelEdge;

public class PetrifierArc implements Serializable {
	private static final long serialVersionUID = -6564134138868271853L;
	private String id;
	private String source;
	private String target;
	private int weight = 1;
	private PetrifierArcType type;

	private PetrifierArc() {}
	
	public PetrifierArc(String id, String source, String target, PetrifierArcType type) {
		this();
		this.id = id;
		this.source = source;
		this.target = target;
		this.type = type;
		
		// TODO implement weights
		//weight = edge.getWeightAsInt();
	}
	
	public PetrifierArc(CytoscapeWebNetworkModelEdge edge) {
		this();
		id = edge.getId();
		source = edge.getSource();
		target = edge.getTarget();
		type = PetrifierArcType.valueOf(edge.getDataFieldAsString(PetrifierDataFieldName.ARC_ELEMENT_TYPE.name()));
		
		// TODO implement weights
		//weight = edge.getWeightAsInt();
	}
	
	public String getId() {
		return id;
	}
	public String getSource() {
		return source;
	}
	public String getTarget() {
		return target;
	}
	public PetrifierArcType getType() {
		return type;
	}
	public int getWeight() {
		return weight;
	}
	
	public CytoscapeWebNetworkModelEdge cytoscapeWebNetworkModelEdge() {
		CytoscapeWebNetworkModelEdge obj = (CytoscapeWebNetworkModelEdge) JavaScriptObject.createObject();
		obj.setId(id);
		obj.setSource(source);
		obj.setTarget(target);
		obj.setDataField(PetrifierDataFieldName.ARC_ELEMENT_TYPE.name(), type.name());
		return obj;
	}
}
